<style lang="less">
    @import '../../styles/common.less';
    @import '../tables/components/table.less';
</style>
<template>
    <div>
        <form action="" style="margin: 5px 0;overflow: hidden">
            <Input v-model="name"   placeholder="根据用户名查找"  style="width: 200px;margin-right: 3px;"></Input>
            <Input v-model="phone"  placeholder="根据手机号查找"  style="width: 200px"></Input>
            <Input v-model="num"  placeholder="请输入最低金额"  style="width: 200px"></Input>
            <DatePicker v-model="zcks" type="datetime" placeholder="请输入提现开始时间" style="width: 200px"></DatePicker>
            <DatePicker v-model="zcjs" type="datetime" placeholder="请输入提现结束时间" style="width: 200px"></DatePicker>
            <span style="margin-left: 10px;line-height: 30px;">总额: {{sum}}</span>
            <div style="float: right">
            <Button type="info"  style="float: right;margin-right: 5px" @click="load">查询</Button>
            </div>
        </form>
        <Table :loading="loading" refs="table1"  :data="Message" :columns="columnsList"></Table>
        <Page :total="pageNum" :page-size="pageSize"  style="text-align: center;margin-top: 15px;" show-total @on-page-size-change='pageSizes'  show-elevator show-sizer @on-change="pageChange"></Page>
    </div>
</template>
<script>
    import $http from '../../utils/axiosWrap'
    import canEditTable from '../tables/components/canEditTable.vue'
    export default {
        data() {
            return {
                auditorUser:'',
                userName:'',
                auditorStatus:'',
                rank:'',
                loading: true,
                Message:[],
                admin:true,
                columnsList: [
                    {
                        title: '序号',
                        type: 'index',
                        width: 80,
                        align: 'center'
                    },

                    {
                        title: '转账用户名',
                        align: 'center',
                        key: 'tradeRealname'
                    },
                    {
                        title: '转账人手机号码',
                        align: 'center',
                        key: 'tradePhone',
                        editable: true
                    },

                    {
                        title: '转币数量',
                        align: 'center',
                        key: 'tradeCurrencyNumber',
                        editable: true
                    },
                    {
                        title: '收账人用户名',
                        align: 'center',
                        key: 'transferRealname',
                        editable: true
                    },
                    {
                        title: '收账人手机号',
                        align: 'center',
                        key: 'transferPhone',
                        editable: true
                    },
                    {
                        title: '交易时间',
                        align: 'center',
                        width: 160,
                        key: 'tradeCreateTime'
                    }
                ],
                name: '',
                phone: '',
                zcks:'',
                zcjs:'',
                num:'',
                pageNum:0,
                initPage:1,
                sum:0,
                pageSize:10
            }
        },
        created: function () {
            this.load()
        },
            methods: {
                setTime(time){
                    var date = new Date(time);
                    var month = date.getMonth() + 1
                    var day =  date.getDate()
                    var hours =   date.getHours()
                    var minutes = date.getMinutes()
                    var datese = date.getSeconds()
                    if(datese /1  < 10){
                        datese = '0' +  datese
                    }
                    if(month /1  < 10){
                        month = '0' +  month
                    }
                    if(day /1  < 10){
                        day = '0' +  day
                    }
                    if(hours /1  < 10){
                        hours = '0' +  hours
                    }
                    if(minutes /1  < 10){
                        minutes = '0' +  minutes
                    }
                    return date.getFullYear() + '-' + month + '-' + day + ' ' + hours + ':' + minutes + ':' + datese
                },
                pageSizes(val){
                    this.pageSize = val
                    this.loading = true
                    this.load()
                },
                pageChange(index){
                    this.initPage = index
                    this.loading = true
                    this.load ()
                },
                load () {
                    let _this = this
                    let params = new URLSearchParams()
                    params.append('page', _this.initPage)
                    params.append('backTransferId', '9')
                    params.append('username', _this.name)
                    params.append('phone', _this.phone)
                    params.append('tradeNumber', _this.num)
                    params.append('pageSize', _this.pageSize)
                    if(_this.zcks){
                        params.append('createtime', _this.setTime(_this.zcks))
                    }else{
                        params.append('createtime','')
                    }
                    if(_this.zcjs){
                        params.append('endtime', _this.setTime(_this.zcjs))
                    }else{
                        params.append('endtime','')
                    }
                    $http.post('/backgroundExchangeUsd/intoPlatform', params).then(function (res) {
                        if(res.suc){
                        _this.Message = res.result.rows
                        _this.loading = false
                        _this.pageNum = res.result.total
                    }else{
                        if(res.msg == "请先登录"){
                            _this.$Message.error('请重新登录！');
                        }else{
                            _this.$Message.error(res.msg);
                        }
                    }
                    })
                    let paramss = new URLSearchParams()
                    paramss.append('backTransferId', '9')
                    paramss.append('username', _this.name)
                    paramss.append('phone', _this.phone)
                    paramss.append('tradeNumber', _this.num)
                    if(_this.zcks){
                        paramss.append('createtime', _this.setTime(_this.zcks))
                    }else{
                        paramss.append('createtime','')
                    }
                    if(_this.zcjs){
                        paramss.append('endtime', _this.setTime(_this.zcjs))
                    }else{
                        paramss.append('endtime','')
                    }
                    $http.post('/backgroundExchangeUsd/intoPlatformOne',paramss).then(function (ress) {
                        console.log(ress)
                        _this.sum = ress.result.查询总值
                    })
                }
            }
    }
</script>
<style>
    .ivu-form-item {
        margin-bottom: 5px;
    }
</style>

